<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class data_karyawan extends Default_My_Model {

    private $QRY = "SELECT a.*, b.* FROM mt_karyawan a LEFT JOIN mt_divisi b on (a.id_divisi=b.id_divisi) ";
    
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    public function getDataResumeKaryawan() {
        $resultSet = $this->db->query($this->QRY);
        return $resultSet;
    }
    
    public function getDataAllKaryawan($whr) {
        $resultSet = array();
        if ($whr != "") {
            $resultSet['data'] = $this->db->query($this->QRY ." where a.nik !='xx11xx' and " . $whr . " order by nik DESC");
        } else {
            $resultSet['data'] = $this->db->query($this->QRY . " where a.nik !='xx11xx' order by nik DESC");
        }
        $resultSet['last_query'] = $this->db->last_query();
        return $resultSet;
    }
    
    public function getDataKaryawan($whr, $sc_pageslimit, $offset) {
        if ($whr != "") {
            $this->QRY = $this->QRY . " where a.nik !='xx11xx' and " . $whr. " order by nik DESC LIMIT " . $sc_pageslimit . " OFFSET " . $offset;
        } else {
            $this->QRY = $this->QRY. " where a.nik !='xx11xx' order by nik DESC LIMIT " . $sc_pageslimit . " OFFSET " . $offset;
        }
        $resultSet = $this->db->query($this->QRY);
        return $resultSet;
        
    }
    
    public function removeDataKaryawan($nik) {
        $this->db->where('nik', $nik);
        $this->db->delete('mt_karyawan', $where);
    }

}

?>